package com.appforged.AppForged;

import com.appforged.AppForged1.R;

import android.app.Activity;
import android.media.MediaPlayer;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.SlidingDrawer;
import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.SlidingDrawer.OnDrawerOpenListener;

public class Slider extends Activity implements OnCheckedChangeListener,
		OnClickListener, OnDrawerOpenListener {
	SlidingDrawer sd;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.sliding);
		Button button1 = (Button) findViewById(R.id.button1);
		Button button2 = (Button) findViewById(R.id.button2);
		Button button3 = (Button) findViewById(R.id.button3);
		Button handle = (Button) findViewById(R.id.handle);
		CheckBox checkbox = (CheckBox) findViewById(R.id.cBSlide);
		checkbox.setOnCheckedChangeListener(this);
		sd = (SlidingDrawer) findViewById(R.id.slidingD);
		sd.setOnDrawerOpenListener(this);
		button1.setOnClickListener(this);
		button2.setOnClickListener(this);
		button3.setOnClickListener(this);
		handle.setOnClickListener(this);

	}

	public void onClick(View arg0) {

		switch (arg0.getId()) {
		case R.id.button1:
			sd.open();
			break;
		case R.id.button2:
			sd.toggle();
			break;

		case R.id.button3:
			sd.close();
			break;
		case R.id.handle:
			
			break;

		default:
			break;
		}

	}

	public void onCheckedChanged(CompoundButton arg0, boolean arg1) {
		if (arg0.isChecked()) {
			sd.lock();
		} else {
			sd.unlock();
		}

	}

	public void onDrawerOpened() {
		MediaPlayer mp = MediaPlayer.create(this, R.raw.explosion);
		mp.start();

	}

}
